

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>试卷管理</title>
    <#include "/common/link.ftl">

</head>
<body class="hold-transition skin-black sidebar-mini">
<div class="wrapper">
    <#include "/common/navbar.ftl">
    <#assign currentMenu="exam"/>
    <#include "/common/menu.ftl">
    <div class="content-wrapper">
        <section class="content-header">
            <h1>试卷编辑</h1>
        </section>
        <section class="content">
            <div class="box" style="padding: 10px">
                <form class="form-horizontal" action="/exam/save" method="post" id="editForm" >

                    <input type="hidden"  name="id">
                    <div class="form-group"  style="margin-top: 10px;">
                        <label  class="col-sm-2 control-label">试卷名称：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control"  placeholder="请输入试卷名称" name="title" value="">
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-2 control-label">考试时长：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control"   placeholder="请输入考试时长" name="examMinute" value="">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">单选题：</label>

                        <div class="col-sm-3">
                            <#--value为默认值，我不写，默认就为空-->
                            <input type="text" class="form-control form-score" name="singleQuestionCount" value="3"  placeholder="请输入随机组题数量">
                        </div>

                        <div class="col-sm-3">
                            <input type="text" class="form-control form-score"  name="singleScore" value="5"  placeholder="请输入每题分数">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">多选题：</label>

                        <div class="col-sm-3">
                            <input type="text" class="form-control form-score" name="multiQuestionCount" value="2"  placeholder="请输入随机组题数量">
                        </div>

                        <div class="col-sm-3">
                            <input type="text" class="form-control form-score" name="multiScore" value="10"   placeholder="请输入每题分数">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">判断题：</label>

                        <div class="col-sm-3">
                            <input type="text" class="form-control form-score" name="judgementQuestionCount" value="2"   placeholder="请输入随机组题数量">
                        </div>

                        <div class="col-sm-3">
                            <input type="text" class="form-control form-score"  name="judgementScore" value="5" placeholder="请输入每题分数">
                        </div>
                    </div>


                    <div class="form-group">
                        <label class="col-sm-2 control-label">试卷总分：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control"  name="totalScore" value=""  placeholder="请输入试卷总分">
                        </div>
                    </div>

                    <div class="form-group">
                        <div class="col-sm-offset-6 col-sm-6">
                            <button type="submit" class="btn btn-primary btn-submi">生成试卷</button>
                            <a href="javascript:window.history.back()" class="btn btn-danger">取消</a>
                        </div>
                    </div>

                </form>
            </div>
        </section>
    </div>
    <#include "/common/footer.ftl">
</div>

<script>
    //使用时提交的路径是上面action中有的路径
    $("#editForm").ajaxForm(function (data) {
        if (data.success) {
            Swal.fire({
                /*text: '确认生成?',*/
                icon: 'success',
                confirmButtonColor: '#3085d6',
                cancelButtonColor: '#d33',
                confirmButtonText: '生成成功'
            }).then((result) => {
                //window.location.reload();
                console.log(data.data)
                window.location.href = '/exam/show?id='+data.data;
            })
        } else {
            Swal.fire(
                data.msg,
                '',
                'error'
            )
        }
    })
</script>
<script>
    $(".form-score").change(function () {
        var totalSCore = $('input[name=singleScore]').val() * $('input[name=singleQuestionCount]').val()
            + $('input[name=multiQuestionCount]').val() * $('input[name=multiScore]').val()
            + $('input[name=judgementQuestionCount]').val() * $('input[name=judgementScore]').val();
        $('input[name=totalScore]').val(totalSCore);
    })
</script>
</body>
</html>
